<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>俱乐部</title>
    <th:block th:include="fragments/header :: header"/>
    <script type="text/javascript" th:inline="none">

        $(function () {
            initDataGrid();
            initToolbar();
        });

        //初始化表格
        function initDataGrid() {
            $("#dgClubList").datagrid({
                url: '/markt/club/list',
                idField: 'id',
                frozenColumns:[[
                    {field:'ck',checkbox:true}
                ]],
                columns: [[
                    {field: 'name', title: '名称', width: 150,formatter:function (value,row,index) {
                        return "<a href='/markt/club/detail/"+row.id+"'>"+row.name+"</a>"
                    }},
                    {field:'levelName',title:'等级',width:80}
                ]],
                pagination:true,
                rownumbers:true,
                fit:true,
                toolbar:'#dgClubList-toolbar'
            })
        }

        //初始化工具条
        function initToolbar() {
            $("#btnAdd").click(function () {
                layer.open({
                    type: 2,
                    content: '/markt/club/add',
                    area:['500px','300px'],
                    btn:['确定','取消'],
                    yes:function (index,layero) {
                        var iframe = $(layero).find("iframe")[0].contentWindow;
                        iframe.submitForm();
                        layer.close(index);
                        window.parent.location.reload();
                    }
                });
            });

            $("#btnEdit").click(function () {
                var sel = $("#dgClubList").datagrid('getSelected');
                if (sel) {
                    layer.open({
                        type: 2,
                        content: '/markt/club/edit/' + sel.id,
                        area:['500px','300px'],
                        btn:['确定','取消'],
                        yes:function (index,layero) {
                            var iframe = $(layero).find("iframe")[0].contentWindow;
                            iframe.submitForm();
                            layer.close(index);
                            window.parent.location.reload();
                        }
                    });
                }
            });

            $("#btnRemove").click(function () {
                DataGridUtil.Delete("/markt/club/doDelete","dgClubList");
            });

            $("#btnImportExcel").click(function () {
                layer.open({
                    type:2,
                    content: '/markt/importExcel?type=club',
                    area:['500px','300px'],
                    end:function () {
                        window.parent.location.reload();
                    }
                })
            });
        }
    </script>
</head>
<body class="easyui-layout">
<div id="dgClubList-toolbar" style="padding: 2px 0;" class="datagrid-toolbar">
    <table cellpadding="0" cellspacing="0" style="width: 100%">
        <tr>
            <td style="padding-left: 2px">
                <a id="btnAdd" href="javascript:void(0)" class="easyui-linkbutton">新增</a>
                <a id="btnEdit" href="javascript:void(0)" class="easyui-linkbutton">编辑</a>
                <a id="btnRemove" href="javascript:void(0)" class="easyui-linkbutton">删除</a>
                <div class="datagrid-btn-separator"></div>
                <a id="btnImportExcel" href="javascript:void(0)" class="easyui-linkbutton">导入Excel</a>
            </td>
        </tr>
    </table>
</div>
<div data-options="region:'center'">
    <table id="dgClubList">
    </table>
</div>
</body>
</html>
